﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog x-modal-dialog" style="width:800px; margin-top: 50px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-fire" title="创建订单"></i>&nbsp;&nbsp;导入渠道记录</h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/user-source/import"  enctype="multipart/form-data" data-validate="true">
    
     <c:if test="${currentPrincipal.siteManager or currentPrincipal.siteServer}">
        <input type="hidden" name="siteId" value="${currentPrincipal.site.id}">
      </c:if>
      
     <c:if test="${currentPrincipal.root or currentPrincipal.admin or currentPrincipal.areaServer or currentPrincipal.areaManager}">
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">门店</label>
          <div class="col-xs-3">
            <select name="siteId" class="form-control" data-validate="required">
              <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                <option value="${site.id}">${site.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>
      </c:if>
      
      <div class="modal-body">
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">文件</label>
          <div class="col-xs-6" style="padding-right: 0px;">
            <label class="form-control file-container">
               <span data-placeholder="点击上传渠道记录"><span class="label label-primary" style="float: right; font-size: 14px;">select file</span></span>
               <input name="sourceList" type="file" accept="application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" data-validate="required"></input>
            </label>
          </div>
          <div class="col-xs-2" style="padding-left: 5px;">
            <a href="${ctx.resource}/templates/user-source-template.xlsx" style="width: 100%;padding: 6px 12px;line-height: 36px;color: #D88362;text-align: center;" download="">Template</a>
          </div>
        </div>
      </div>

      <div class="modal-footer clearfix">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div> 
    </form>

  </div>

</div>

<script src="${ctx.resource}/js/component/bootstrap.validate.js"></script>
<script src="${ctx.resource}/js/component/bootstrap.validate.en.js"></script>
<script src="${ctx.resource}/js/bootstrap.validate.trigger.js"></script>
<script>
$(document).ready(function(){
	
  
  $('select[name="siteId"]').select2({
      placeholder : '请选择门店',
      minimumResultsForSearch : 5,
      allowClear : true,
    });
  
});
</script>